package knapsackProblem;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


public final class WorkerStateSet{
	private static volatile List<WorkerState> orderedWorkers = null;
	
	public static void addWorkers(int howManyWorkers){
		if (orderedWorkers == null ) {
			synchronized (WorkerStateSet.class) {
				if (orderedWorkers == null ) 
					orderedWorkers = new ArrayList<WorkerState>(howManyWorkers);
				}
			}
		
		for(int i=0;i<howManyWorkers;i++)
			orderedWorkers.add(new WorkerState());		
	}
	
	private WorkerStateSet(){};

	
public class WorkerStateComparator implements Comparator<WorkerState> {
	@Override
	public int compare(WorkerState ws1, WorkerState ws2) {
		return ws1.getTimeToFinish().compareTo(ws2.getTimeToFinish());
	}}
}